package com.atguigu.gmall.common.config.minio;

import com.atguigu.gmall.common.config.minio.properties.AppMinioPrpperties;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName AppMinioConfiguration
 * @Description 此类描述:
 * @Author dangchen
 * @DateTime 2022-11-02 8:41
 * @Version 1.0
 */
@Configuration
@EnableConfigurationProperties(AppMinioPrpperties.class)//1.让整个属性绑定做完,2 把AppMinioPrpperties放到容器中
public class AppMinioConfiguration {

    @Autowired
    AppMinioPrpperties appMinioPrpperties;

    @Bean
    public MinioClient minioClient() throws Exception {
        MinioClient minioClient = new MinioClient(appMinioPrpperties.getEndpoint(),
                appMinioPrpperties.getAccessKey(),
                appMinioPrpperties.getSecretKey());
        return minioClient;
    }
}
